<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>事件绑定</title>
    <style>
        #outer{
            width: 500px;
            height: 500px;
            background-color: red;
        }
        #mid{
            width: 400px;
            height: 400px;
            background-color: skyblue;
        }
        #inner{
            width: 300px;
            height: 300px;
            background-color: orange;
        }
    </style>
</head>
<body>
    <div id="app">
        <div id="outer" >
            <div id="mid">
                <div id="inner"></div>
            </div>
        </div>
    </div>
<script>

    const outer=document.getElementById("outer");
    const mid=document.getElementById("mid");
    const inner=document.getElementById("inner");
    /* 
    capture的用法
        1.三个元素添加相同的事件，点击inner的div -----------》执行顺序：  inner ---mid --- outer
        2.outer事件中加入capture  点击inner --------------》执行顺序：  outer --- inner --- mid
        3.三个事件中加入capture  点击inner/mid/outer 事件的触发从捕获阶段开始一直打印------>outer --- mid --- inner
    once的用法


    */
    // outer.addEventListener("click",outerClick,"false")
    outer.addEventListener("click",outerClick,"once:true")
    // outer.addEventListener("click",outerClick)
    function outerClick(){
        console.log("outer被点击了");
    }


    outer.addEventListener("click",midClick,"capture:false")
    // mid.addEventListener("click",midClick)
    function midClick(){
        console.log("mid被点击了");
    }

    outer.addEventListener("click",innerClick,"capture:false")
    // inner.addEventListener("click",innerClick)
    function innerClick(){
        console.log("inner被点击了");
    }
</script>
</body>
</html>